package com.scgl.process.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

//import com.ruoyi.common.log.annotation.Log;

import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.scgl.process.domain.ScglCea;
import com.scgl.process.service.IScglCeaService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 产品信息Controller
 *
 * @author ruoyi
 * @date 2024-11-01
 */
@RestController
@RequestMapping("/cea")
public class ScglCeaController extends BaseController
{
    @Autowired
    private IScglCeaService scglCeaService;

    /**
     * 查询产品信息列表
     */
    @RequiresPermissions("process:cea:list")
    @GetMapping("/list")
    public TableDataInfo list(ScglCea scglCea)
    {
        startPage();
        List<ScglCea> list = scglCeaService.selectScglCeaList(scglCea);
        return getDataTable(list);
    }

    /**
     * 导出产品信息列表
     */
    @RequiresPermissions("process:cea:export")
    @PostMapping("/export")
    public void export(HttpServletResponse response, ScglCea scglCea)
    {
        List<ScglCea> list = scglCeaService.selectScglCeaList(scglCea);
        ExcelUtil<ScglCea> util = new ExcelUtil<ScglCea>(ScglCea.class);
        util.exportExcel(response, list, "产品信息数据");
    }

    /**
     * 获取产品信息详细信息
     */
    @RequiresPermissions("process:cea:query")
    @GetMapping(value = "/{processName}")
    public AjaxResult getInfo(@PathVariable("processName") String processName)
    {
        return success(scglCeaService.selectScglCeaByProcessName(processName));
    }

    /**
     * 新增产品信息
     */
    @RequiresPermissions("process:cea:add")
    @Log(title = "产品信息添加", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ScglCea scglCea)
    {
        return toAjax(scglCeaService.insertScglCea(scglCea));
    }

    /**
     * 修改产品信息
     */
    @RequiresPermissions("process:cea:edit")
    @Log(title = "产品信息修改", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ScglCea scglCea)
    {
        return toAjax(scglCeaService.updateScglCea(scglCea));
    }

    /**
     * 删除产品信息
     */
    @RequiresPermissions("process:cea:remove")
    @Log(title = "产品信息删除", businessType = BusinessType.DELETE)
	@DeleteMapping("/{processNames}")
    public AjaxResult remove(@PathVariable String[] processNames)
    {
        return toAjax(scglCeaService.deleteScglCeaByProcessNames(processNames));
    }
}
